import { createApp } from 'vue'
import App from './App.vue'
import router from './router'

import './plugins/element.js'

// css样式初始化
import './assets/css/global.css'

// 引入样式图标库
import './assets/fonts/iconfont.css'

// 富文本框
import { QuillEditor } from '@vueup/vue-quill'
import '@vueup/vue-quill/dist/vue-quill.snow.css'

// 进度条导入
import 'nprogress/nprogress.css'

var app = createApp(App)

app.config.globalProperties.$message = ElMessage
app.config.globalProperties.$messageBox = ElMessageBox
app.config.globalProperties.$filters = {
    dateFormat(originVal){
        const dt = new Date(originVal);

        const y = dt.getFullYear();
        const m = (dt.getMonth() + 1 + '').length == 1 ? '0' + (dt.getMonth() + 1) : dt.getMonth() + '';
        const d = (dt.getDate() + '').length == 1 ? '0' + (dt.getDate()) : dt.getDate() + '';

        const hh = (dt.getHours() + '').length == 1? '0' + (dt.getHours()) : dt.getHours() + '';
        const mm = (dt.getMinutes() + '').length == 1 ? '0' + (dt.getMinutes()) : dt.getMinutes() + ''; 
        const ss = (dt.getSeconds() + '').length == 1 ? '0' + (dt.getSeconds()) : dt.getSeconds() + '';

        return `${y}-${m}-${d} ${hh}:${mm}:${ss}`;
    }
}

app.component('QuillEditor', QuillEditor)

app.use(router).mount('#app')
